<?php
use yii\helpers\Html;
use yii\widgets\DetailView;
use app\modules\Product\models\ProductRoomPrice;
use app\modules\Order\models\OrderRoom;

?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title></title>
    <style type="text/css">
     
      
        #printBtn{background: #FF9;border-bottom: 1px solid #999;padding: 3px 0;margin-bottom: 10px;text-align: center;}
        #wrapper{
                width: 300mm;
                margin: 0 auto;
                text-align: left;
                background: white;
                padding: 20mm;
                border-top: 1px solid #999;
                border-left: 1px solid #999;
                border-right: 4px solid #333;
                border-bottom: 4px solid #333;
        }
  
    </style>
</head>
<body>


<!-- <div id="printBtn">
    <a href="#" onclick="javascript:XDoc();">[另存为doc]</a>
   <a href="#" onclick="javascript:show();">[隐藏同业价格]</a> 
</div> -->




<div id="wrapper">

    <p style='text-align: center;'>
        <span style='font-family:"微软雅黑体";font-weight: bold;color: #4FB1BF;text-align: center;font-size: 20px;'><?=$model->name?></span>
    </p>
    <p>&nbsp;</p>
    <p><span style='font-size: 14px;font-family: "黑体";'><?=$model->cruise->desc;?></span></p>
    <p>&nbsp;</p>

    <div class="detail" style="width: 300mm;">
        <p><span style='font-size: 16px;font-family:"黑体";font-weight: bold;margin-bottom:3mm;'><?=sprintf("行程介绍： (%s - %s)", $model->go_time, $model->return_time);?></span></p>
        <p>&nbsp;</p>
            <?php 
                  $weekarray = array("日","一","二","三","四","五","六");  
                  $trip = json_decode($model->trip, true);
                  ksort($trip);   
                  $dates = Yii::$app->dates->prDates($model->go_time, $model->return_time);
            ?>
     
        <?php if($model->type == 2 || $model->type == 3){ ?>
        <?php 
          $trip_img = [];
          if(!empty($model->trip_img)){
             $trip_img = json_decode($model->trip_img,true);
          }

        ?>
        <div style="width: 300mm">
            <?php foreach($trip as $key=>$val){?>
            <div class="day">
                <div class="day_title">
                    <span style='font-weight: bold;font-family:"黑体";font-size: 20px;color:#0070C0;'><?=sprintf("第%s天", $key+1);?></span>
                    <span style='font-size: 14px;font-family:"黑体";color: #000;font-weight: bold;'><?=date("Y年m月d日",strtotime($dates[$key]))?> 周<?=$weekarray[date("w",strtotime($dates[$key]))]?> | <?=$val['title']?><?php if(!empty($val['time1']) || !empty($val['time2'])){?>  邮轮预计<?php if(!empty($val['time1'])){?><?=$val['time1']?> 抵港 <?php };?><?php if(!empty($val['time2'])){?><?=$val['time2']?> 离港 <?php };?>
                        <?php }?>
                    </span>
                </div>

                <div class="day_img" style="width:100%;">
                <?php if(isset($trip_img[$key]) && !empty($trip_img[$key])){?>

                  <?php foreach($trip_img[$key] as $kimg=>$vimg){ ?> 
                      
                        <img src="<?=\Yii::$app->params['qiniu_path'].$vimg.'?imageView2/2/w/280/'?>" style="width:150mm;float: left;"?>
                     
                   <?php }?>
                 <?php }?>     
                </div>
                <p>&nbsp;</p> 
                <div class="day_detial" style="margin-top: 10mm;margin-bottom: 10mm;">
                    <p><span style='font-size: 12px;font-family:"黑体";'><?=$val['desc']?></span></p>
                </div>

                <div class="day_other" style="margin-top: 10mm;margin-bottom: 10mm;margin-left: 20px;">
                    <p><span style='font-size: 12px;font-family:"黑体";'>餐食：<?=!empty($val['eat'])?$val['eat']:'无';?></span></p>
                    <p><span style='font-size: 12px;font-family:"黑体";'>交通：<?=(isset($val['traffic']) && !empty($val['traffic']))?$val['traffic']:'无';?></span></p>
                    <p><span style='font-size: 12px;font-family:"黑体";'>住宿：<?=!empty($val['room'])?$val['room']:'无';?></span></p>
                </div>

            </div> 
            <p>&nbsp;</p>  
            <?php }?>  
        </div>    
        <?php }?>

    </div>

    <?php if(!empty($model->sale)){?>
    <p>&nbsp;</p>
    <div style="margin-top: 10mm;">
        <p style='font-family:"黑体";color:red;font-size: 16px;font-weight: bold;'>优惠信息:</p>
        <div style='font-family:"黑体";font-size: 14px;margin-left: 20px;color: red'><?=$model->sale;?></div>
    </div>    
    <?php }?>
    
    <div style="margin-top: 10px;">
         <p><span style='font-size: 16px;font-weight: bold;margin-bottom:3mm;font-family:"黑体";'><?=sprintf("%s参团产品销售价格:", $model->code);?></span></p>
         
         <?php if($model->stock == 1){ ?>
             <table width="300mm" style="table-layout: fixed;border-collapse: collapse;">
                <thead>
                    <tr>
                        <th width="40%" style="background: #4FB1BF;"><p style='text-align: center;font-family:"黑体";color:#FFFFFF;font-size: 14px;font-weight: bold;'>舱型</p></th>
                        <th width="20%" style="background: #4FB1BF;"><p  style='text-align: center;font-family:"黑体";color:#FFFFFF;font-size: 14px;font-weight: bold;'>楼层</p></th>
                        <th width="20%" style="background: #4FB1BF;"><p  style='text-align: center;font-family:"黑体";color:#FFFFFF;font-size: 14px;font-weight: bold;'>外卖价/人</p></th>
                        <?php if($type == 1){ ?>
                        <th class="in-show" width="20%" style="background: #4FB1BF;"><p  style='text-align: center;font-family:"黑体";color:#FFFFFF;font-size: 14px;font-weight: bold;'>同行价/人</p></th>
                         <?php }?>
                    </tr>

                </thead>
                <tbody>
                <?php  foreach($model->productRoom as $val){ ?>
                     <?php if($val->show ==1 && !empty($val->price)){ ?>   
                        <?php
                        $name = sprintf("%s%s %s人房",$val->room->name, $val->room->code, $val->people); 
                        ?>
                        <tr>
                            <td><p style='text-align: center;font-family:"黑体";color:#000000;font-size: 14px;'><?=$name?></p></td>
                            <td><p style='text-align: center;font-family:"黑体";color:#000000;font-size: 14px;'><?=yii::$app->ceils->getCeils($val->room->ceil)?></p></td>
                            <td><p style='text-align: center;font-family:"黑体";color:red;font-size: 14px;'>
                                <?php if(isset($val->sell_out) && $val->sell_out == 1){ ?>
                                    售罄
                                <?php }else{ ?>
                                    <?=$val->price?>
                                <?php }?>
                                </p></td>
                            <?php if($type == 1){ ?>
                            <td><p style='text-align: center;font-family:"黑体";color:red;font-size: 14px;'>
                                <?php if(isset($val->sell_out) && $val->sell_out == 1){ ?>
                                    售罄
                                <?php }else{ ?>
                                    <?=$val->inside_price?>
                                <?php }?>
                                </p></td>
                            <?php }?>
                        </tr>
                       <?php };?> 
                   
                    <?php };?>
         

                </tbody>
            </table>   
        <?php }elseif($model->stock == 2){?>
        
             <table class="table_price2"  width="300mm" style="table-layout: fixed;border-collapse: collapse;">
                <thead>
                    <tr>
                        <th width="15%" style="background: #4FB1BF;"><p style='text-align: center;font-family:"黑体";color:#FFFFFF;font-size: 14px;font-weight: bold;'>名称</p></th>
                        <th width="15%" style="background: #4FB1BF;"><p style='text-align: center;font-family:"黑体";color:#FFFFFF;font-size: 14px;font-weight: bold;'>第1/2人价格</p></th>
                        <?php if($type == 1){ ?>
                        <th class="in-show" width="15%" style="background: #4FB1BF;"><p style='text-align: center;font-family:"黑体";color:#FFFFFF;font-size: 14px;font-weight: bold;'>第1/2人同业价格</p></th>
                        <?php }?>
                        <th width="15%" style="background: #4FB1BF;"><p style='text-align: center;font-family:"黑体";color:#FFFFFF;font-size: 14px;font-weight: bold;'>第3/4人价格</p></th>
                        <?php if($type == 1){ ?>
                        <th class="in-show" width="15%" style="background: #4FB1BF;"><p style='text-align: center;font-family:"黑体";color:#FFFFFF;font-size: 14px;font-weight: bold;'>第3/4人同业价格</p></th>
                        <?php }?>
                        <th width="10%" style="background: #4FB1BF;"><p style='text-align: center;font-family:"黑体";color:#FFFFFF;font-size: 14px;font-weight: bold;'>单间差</p></th>
                        <th width="15%" style="background: #4FB1BF;"><p style='text-align: center;font-family:"黑体";color:#FFFFFF;font-size: 14px;font-weight: bold;'>备注</p></th>
                    </tr>

                </thead>
                <tbody>
                <?php if(!empty($model->rooms)){ 
                         $data_rooms = json_decode($model->rooms,true);
                ?>
                <?php   if(is_array($data_rooms)){ ?>
                <?php foreach($data_rooms as $rid=>$val){?>
                         <?php 
                            $use_num = 0;
                            $use_num = OrderRoom::find()->where(['room_id'=>$rid,'product_id'=>$model->id,'status'=>1])->count();
                        ?>
                        <tr>
                        <td><p style='text-align: center;font-family:"黑体";color:#000;font-size: 14px;'><?=(!empty($val['name']))?$val['name']:"—";?></p></td>
                        <td><p style='text-align: center;font-family:"黑体";color:red;font-size: 14px;'>
                           <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                 <?=(!empty($val['price']))?$val['price']:"—";?>
                            <?php }?>     
                            </p>
                        </td>
                        <?php if($type == 1){ ?>
                        <td class="in-show"><p style='text-align: center;font-family:"黑体";color:red;font-size: 14px;'>
                             <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                <?=(!empty($val['inside_price']))?$val['inside_price']:"—";?>
                            <?php }?>  </p></td>
                        <?php }?>
                        <td><p style='text-align: center;font-family:"黑体";color:red;font-size: 14px;'>
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                <?=(!empty($val['price2']))?$val['price2']:"—";?>
                            <?php }?>  </p></td>
                        <?php if($type == 1){ ?>
                        <td class="in-show"><p style='text-align: center;font-family:"黑体";color:red;font-size: 14px;'>
                            <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                 <?=(!empty($val['inside_price2']))?$val['inside_price2']:"—";?>
                            <?php }?>  
                            </p></td>
                        <?php }?>
                        <td><p style='text-align: center;font-family:"黑体";color:red;font-size: 14px;'>
                           <?php if(isset($val['sell_out']) && $val['sell_out'] == 1){ ?>
                                   售罄
                            <?php }else{?>
                                  <?=(!empty($val['difference']))?$val['difference']:"—";?>
                            <?php }?></p></td>
                        <td><p style='text-align: center;font-family:"黑体";color:#000;font-size: 14px;'><?=(!empty($val['remark']))?$val['remark']:"—";?></p></td>
                        </tr>
                <?php };?>
                <?php };?>
                <?php };?>    
                </tbody>
            </table>   

        <?php }?>    
        
    </div>

    <p>&nbsp;</p>
    <?php if(!empty($model->cost)){?>
    <div style="margin-top: 10mm;">
        <p style='font-family:"黑体";color:#000;font-size: 18px;font-weight: bold;'>费用包含:</p>
        <div style='font-family:"黑体";font-size: 14px;margin-left: 20px;'><?=$model->cost;?></div>
    </div>    
    <?php }?>

    <?php if(!empty($model->nocost)){?>
    <p>&nbsp;</p>
    <div style="margin-top: 10mm;">
        <p style='font-family:"黑体";color:#000;font-size: 18px;font-weight: bold;'>费用不包含:</p>
        <div style='font-family:"黑体";font-size: 14px;margin-left: 20px;'><?=$model->nocost;?></div>
    </div>    
    <?php }?>

    <?php if(!empty($model->cancel)){?>
    <p>&nbsp;</p>
    <div style="margin-top: 10mm;">
        <p style='font-family:"黑体";color:#000;font-size: 18px;font-weight: bold;'>取消政策:</p>
        <div style='font-family:"黑体";font-size: 14px;margin-left: 20px;'><?=$model->cancel;?></div>
    </div>    
    <?php }?>

    
     <?php if(!empty($model->visa)){?>
     <p>&nbsp;</p>
    <div style="margin-top: 10mm;">
        <p style='font-family:"黑体";color:#000;font-size: 18px;font-weight: bold;'>签证说明:</p>
        <div style='font-family:"黑体";font-size: 14px;margin-left: 20px;'><?=$model->visa;?></div>
    </div>    
    <?php }?>
    <?php if(!empty($model->signup)){?>
    <p>&nbsp;</p>
    <div style="margin-top: 10mm;">
        <p style='font-family:"黑体";color:#000;font-size: 18px;font-weight: bold;'>报名须知:</p>
        <div style='font-family:"黑体";font-size: 14px;margin-left: 20px;'><?=$model->signup;?></div>
    </div>    
    <?php }?>
    <?php if(!empty($model->expense)){?>
    <p>&nbsp;</p>
    <div style="margin-top: 10mm;">
        <p style='font-family:"黑体";color:#000;font-size: 18px;font-weight: bold;'>自费项目:</p>
        <div style='font-family:"黑体";font-size: 14px;margin-left: 20px;'><?=$model->expense;?></div>
    </div>    
    <?php }?>

     <p>&nbsp;</p>
     <div style="margin-top: 10mm;">
        <p style='font-family:"黑体";color:#000;font-size: 18px;font-weight: bold;'>岸上游览:</p>
        <div style='font-family:"黑体";font-size: 14px;margin-left: 20px;'>
            <?php foreach($trip as $val){ ?>
               <?php if(isset($val['visit']) && !empty($val['visit'])){ ?>
                    <?php foreach($val['visit'] as $v){ ?>
                    <?php if(!empty($v['name'])){ ?>

                    <div style="margin-top: 10mm;">
                        <p style='color: #0070C0;font-size: 14px;font-family:"黑体";margin-bottom:3mm;'><?=$v['name'];?> <?=$v['price'];?> </p>
                        <div style='margin:0;padding: 0;font-size: 10px;font-family:"黑体";'><?=$v['content'];?></div>
                    </div> 
                    <p>&nbsp;</p>  
                    <?php }?>
                    <?php }?> 
                <?php }?>
            <?php }?>
        </div>
    </div>    
   

</div>

</body>


<script type="text/javascript" src="/js/html-docx-js/html-docx.js"></script>
<script type="text/javascript" src="/js/html-docx-js/vendor/FileSaver.js"></script>
<script type="text/javascript" src="http://www.xdocin.com/xdoc.js"></script>

<script type="text/javascript">
    function docxs(argument) {
        var filename = '<?=$model->name?>'+'.docx';
        var content = document.getElementById("wrapper").innerHTML;
        var converted = htmlDocx.asBlob(content);
        saveAs(converted,filename);
    }
</script>
</html>